home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / schd.bac < prev    next >
Text File  |  1995-03-23  |  8KB  |  167 lines

  1. Article 1517 of comp.sys.handhelds:
  2. From: lishka@uwslh.slh.wisc.edu (Chris Lishka (a.k.a. Chri) )
  3. Subject: HP48sx program: overnight processing and backups
  4. Message-ID: <1990Mar14.192526.18389@uwslh.slh.wisc.edu>
  5. Date: 14 Mar 90 19:25:26 GMT
  6. Reply-To: lishka@uwslh.UUCP (Chris Lishka (a.k.a. Chri) )
  7. Organization: Wisconsin State Laboratory of Hygiene
  8. Lines: 155
  9.  
  10. After reading through the manuals, I wanted to try out the hp48sx programmable
  11. alarm facility and ports.  One thing I wanted to do was save a backup copy of
  12. the system in case I accidentally blow something away (or overwrite it).  This
  13. was a perfect job for an overnight programmable alarm!  So I sat down and wrote
  14. these programs as a general way to run overnight processing.
  15.  
  16. This set of programs sets up a job to run at 3:00am, when I am the least likely
  17. to be programming on it.  The calculator "wakes up," performs a backup and
  18. keypack, and then shuts off again.  The alarm is rescheduled automatically to
  19. run the next night.  I thought others might like to use this technique to run
  20. their own stuff, so I am posting these programs.
  21.  
  22. There are five programs included in this set.  The first three implement the
  23. overnight processing functions:
  24.     * SCHEDULE will set up the alarm.  It should only be run if no overnight
  25.       processing is being done routinely.  I have not tested what happens if
  26.       you try to schedule two or more alarms at the same time.
  27.     * JOB contains the job to be run overnight.  This program is used to call
  28.       other programs (which do the real processing), turn the machine off, and
  29.       print a report (when the machine is turned on again) to let the user know
  30.       the overnight processing ran.
  31.     * REPORT prints a report stating when the overnight processing was run.
  32.  
  33. The other two programs perform specific functions in the overnight processing:
  34.     * BACKUP creates an archive of all memory in the computer and stores it in
  35.       PORT0.  Note that using a straight archive like this effectively reduces
  36.       your usable memory by 50% (half for you to use, half for the archive).
  37.       Since memory is not a big concern to me, I have kept this simple.  You
  38.       will likely want to replace the archive with some smarter scheme that
  39.       uses less memory (possibly something on the order of Bob Peraino's
  40.       archive program for the hp28).  Also note that NO memory checking is done
  41.       to see if enough exists for the new archive.  I leave this as an exercise
  42.       for the reader.
  43.     * KEYPACK reclaims memory used by old programmable (i.e. USER) key
  44.       definitions.  The user's manual mentions that this should be done
  45.       periodically, and early in the morning seems like the best time to do it.
  46.       Note that this should be run before the BACKUP command to free useless
  47.       memory before it is archived.
  48.  
  49. Only the JOB program takes an argument (the number returned by the alarm).
  50. None of the programs return an values.  Accompanying each program name is the
  51. checksum and byte-count as computed by the BYTES command.
  52.  
  53. I have all of this set up in one directory (path = {HOME root LIB NIGHT}).  You
  54. will most likely have a different directory structure than mine, and therefore
  55. you will need to edit the programs to match your system.  Also, make sure the
  56. repeat interval is correct.  I have know idea what a super-short repeat
  57. interval (i.e. less than one second) will do, nor do I really want to find out.
  58.  
  59. I hope you find this helpful.  I really like the programmable alarm feature,
  60. which is much like the Unix CRON facility, except that it is much easier to
  61. start hp48sx alarms than edit a crontab file!
  62.  
  63.                     .oO Chris Oo.
  64.  
  65. Note: I don't yet have a serial cable, and my manuals are at home, so I have
  66. *not* used the HP back-slash sequences for the non-ascii characters.  Here are
  67. the substitutions I used:
  68.  
  69.     << = Program-begin
  70.     >> = Program-end
  71.     -> = Right-pointing-arrow
  72.  
  73.  
  74.   # SCHEDULE sets an alarm to occur at 3am in the morning, with a reschedule/
  75.   # repeat interval of one day.  The contents of the variable JOB (in the
  76.   # current path) are used as the program to be executed.
  77. SCHEDULE  [ #18746d, 74.5 ]
  78.  
  79. <<
  80.   { }                # * Construct a list of arguments for STOALARM
  81.   DATE 1 DATE+ +        # * Make sure it runs *tomorrow* morning.  This
  82.                 #   will need to be changed if you run it
  83.                 #   *before* midnight.
  84.   3 +                # * Run the job at 3am.
  85.   'JOB' RCL +            # * Store the program to be run.  I use the
  86.                 #   contents of variable JOB in the current
  87.                 #   directory.
  88.   707788800 +            # * Repeat interval (1 day)
  89.                 #   = 8192ticks/sec * 60sec * 60min * 24hr
  90.   STOALARM            # * Use the constructed list to set the alarm.
  91. >> 'SCHEDULE' STO
  92.  
  93.   
  94.   # JOB contains the program to be run every night.  It is only accessed by
  95.   # SCHEDULE.  Note that schedule *could* just hand off the name 'JOB' to the
  96.   # alarm, but giving the actual program (i.e. contents of JOB) is safer
  97.   # because the alarm does not have to change to the directory where JOB is
  98.   # located (although currently it does anyway in order to run the KEYPACK
  99.   # and BACKUP programs).
  100. JOB [ #34504d, 87 ]
  101.  
  102. <<
  103.   DROP                # * Drop the value returned by the alarm.
  104.   HOME root LIB NIGHT        # * Switch to the directory which contains the
  105.                 #   programs to run at night.  You will need
  106.                 #   need to change this to suit your system.
  107.   KEYPACK            # * Run the program to free up USER memory.
  108.   BACKUP            # * Run the nightly backup script.
  109.   OFF                # * Put the hp48 back to sleep.
  110.   REPORT            # * Print a report next time the calculator
  111.                 #   is turned on.
  112.   HOME root            # * Change back to the "root" directory. Again,
  113.                 #   you will need to change this to your
  114.                 #   match the directories of your system.
  115. >> 'JOB' STO
  116.  
  117.  
  118.   # REPORT prints a message indicating that the overnight processing was run.
  119.   # If it is run right after the OFF command (in JOB), the message will be
  120.   # displayed the next the calculator is turned on.
  121. REPORT  [ #55113d, 93 ]
  122.  
  123. <<
  124.   CLLCD                # * Clear the screen.
  125.   "Night processing:" 4 DISP    # * Display the message
  126.   DATE TIME TSTR 5 DISP        # * Show the date and time the overnight
  127.                 #   processing ran.
  128.   "Memory: " MEM ->STR +    # 
  129.   6 DISP            # * Also display the remaining memory
  130.   2 FREEZE            # * Keep the information around
  131. >> 'REPORT' STO
  132.  
  133.  
  134.   # BACKUP creates an archive of the current memory in a file in PORT0.  The
  135.   # time the backup was created is also stored.  If you have extra RAM, you may
  136.   # want to change this to save in a different port (swap :1: or :2: for :0:).
  137.   # Also, if you don't want to save the entire memory contents, you can
  138.   # substitute some other command sequence for the ARCHIVE command.
  139. BACKUP  [ #52737d, 92 ]
  140.  
  141. <<
  142.   :0:BACKUP PURGE        # * Remove the previous backup and the record
  143.   :0:BTIME  PURGE        #   of when it was created.
  144.   :0:BACKUP ARCHIVE        # * Create a new archive of the current memory
  145.   DATE TIME TSTR        # * Grab the current date and time.
  146.   :0:BTIME STO            # * Save the time that the backup was run for
  147.                 #   future reference.
  148. >> 'BACKUP' STO
  149.  
  150.  
  151.   # KEYPACK packs the programmable key definitions.  The user's manuals (in the
  152.   # customization chapter, I believe) states that this should be done from time
  153.   # to time to keep memory from chewed up with old key definitions.  The code
  154.   # in this program is straight out of the user's manaul example.
  155. KEYPACK  [ #64094d, 31.5 ]
  156.  
  157. <<
  158.   RCLKEYS 0 DELKEYS STOKEYS    # * Straight from the user's manuals!
  159. >> 'KEYPACK' STO
  160. -- 
  161. Christopher Lishka 608-262-4485  "Somebody said to me, `But the Beatles were
  162. Wisconsin State Lab. of Hygiene  antimaterialistic.'  That's a huge myth.  John
  163.    lishka@uwslh.slh.wisc.edu     and I literally used to sit down and say `Now,
  164.    uunet!uwvax!uwslh!lishka      let's write a swimming pool'."--Paul McCartney
  165.  
  166.  
  167.